package bmatch.tech.cloud.service.impl;

import bmatch.tech.cloud.dao.UserMapper;
import bmatch.tech.cloud.model.User;
import bmatch.tech.cloud.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * UserServiceImpl的注释
 *
 * @author: Awake
 * @date: 2018-12-13 20:57
 **/
@Service
public class UserServiceImpl implements UserService {

    private final UserMapper mapper;

    @Autowired
    public UserServiceImpl(UserMapper mapper) {
        this.mapper = mapper;
    }

    @Override
    public String login(String name, String pwd) {
        List<User> users = mapper.loginQuery(name,pwd);
        if(users.isEmpty()){
            return null;
        }else {
            return users.get(0).getUserId();
        }
    }
}
